﻿@{
    Layout = null;
}



<!DOCTYPE html>
<html>
<head>
    <title>AHoo新闻后台登录界面</title>







    <link href="~/css/StyleSheet.css" rel="stylesheet" />
    <link href="~/elementui/element-ui.css" rel="stylesheet" />


    <style>
        .login {
            background-color: #005377;
            color: #fff;
            padding: 11px;
            outline: none;
            border: none;
            font-size: 17px;
            width: 50%;
            cursor: pointer;
            margin-top: 5px;
            transition: 0.5s all;
            -webkit-transition: 0.5s all;
            -moz-transition: 0.5s all;
            -o-transition: 0.5s all;
            -ms-transition: 0.5s all;
        }

            .login:hover {
                background: #fed14e;
                color: #000;
            }
    </style>
</head>

<body>
    <img src="~/images/logo1.png">
    <div id="app">
        <div class="container w3">
            <h2>AHoo管理员登录</h2>
            <form >
                <div class="username">
                    <span class="username">用户名:</span>
                    <input type="text" v-on:keyup.enter="send" name="name" class="name" v-model="username" placeholder="" required="">
                    <div class="clear"></div>
                </div>
                <div class="password-agileits">
                    <span class="username">密码:</span>
                    <input type="password" v-on:keyup.enter="send" name="password" v-model="password" class="password" placeholder="" required="">
                    <div class="clear"></div>
                </div>
                <div class="rem-for-agile">
                    <input type="checkbox" checked="checked"  name="remember" class="remember">已经阅读安全策略<br>
                    <a href="#">Forgot Password</a><br>
                </div>
                <div class="login-w3">
                    <input type="button" class="login" v-on:click="send" value="登录">
                  
                </div>
                <div class="clear"></div>
            </form>
        </div>
        <div class="footer-w3l">
            <p> &copy; 桂ICP备2023011154号-1 <a href="https://shop585798004.taobao.com/" target="_blank"></a></p>
        </div>
    </div>

</body>
</html>
<script src="~/lib/axios.js"></script>
<script src="~/lib/vue.js"></script>
<script src="~/elementui/element.js"></script>
<script>

    var app = new Vue({
        el: "#app",
        data: {

            msg: "测试",
            username: "",
            password: ""
        }, methods: {
            tiaozhuan() {

             
            },

            send() {
                console.log('点击没');
                if (this.username=="" && this.password == "") {

                    this.$alert('用户名或密码未输入', '信息提示', {
                        confirmButtonText: '确定'
                      
                    });
                    return;
                }
                axios.post('/admin/login', { UserName: this.username, PassWord: this.password }).then(res => {

                    if (res.data.code == 200) {

                
                        if (res.data.code == 200) {

                            alert("登录成功！");
                            setTimeout(2000);

                            location.href = "/admin/index"
                        }
                        console.log(res);
                        console.log(res.data.code == 200);
                    } else {
                        this.$alert('账号或密码错误', '信息提示', {
                            confirmButtonText: '确定'

                        });
                    }
               

                }).catch(err => {

                    console.log(err);
                });
                console.log(this.username, this.password);


            }

        }

    });
</script>